package com.opo5.logisticsmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.opo5.logisticsmanagement.Vo.MaterialVo;
import com.opo5.logisticsmanagement.dao.PlanListDao;
import com.opo5.logisticsmanagement.domain.PlanList;
import com.opo5.logisticsmanagement.service.PlanListService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



@Service
public class PlanListServiceImpl extends ServiceImpl<PlanListDao,PlanList> implements PlanListService {
    @Autowired
    private PlanListDao planListDao;

    @Override
    public IPage<PlanList> selectPage(int currentPage,int pageSize,PlanList planList) {
        LambdaQueryWrapper<PlanList>lqw=new LambdaQueryWrapper<>();
        lqw.eq(planList.getPropertynum()!=null,PlanList::getPropertynum,planList.getPropertynum());
        lqw.orderByAsc(PlanList::getId);
        lqw.eq(Strings.isNotEmpty(planList.getPlantype()),PlanList::getPlantype,planList.getPlantype());
        lqw.eq(planList.getProjectnum()!=null,PlanList::getProjectnum,planList.getProjectnum());
        lqw.like(Strings.isNotEmpty(planList.getProjectname()),PlanList::getProjectname,planList.getProjectname());
        lqw.eq(planList.getPlanstate()!=null,PlanList::getPlanstate,planList.getPlanstate());
        IPage<PlanList>page=new Page<>(currentPage,pageSize);
        planListDao.selectPage(page,lqw);
        return page;
    }

    @Override
    public Page<MaterialVo> getPageVo(Page<MaterialVo> iPage) {
        return planListDao.getElectricity(iPage);
    }
}
